tools/xenstore: fix node accounting after failed node creation
authorJuergen Gross <jgross@suse.com>
Thu, 11 Jun 2020 14:12:39 +0000 (16:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 13:05:47 +0000 (14:05 +0100)
commit3beffb3ed0e999e38a6ff4dec042b38c23d77e48
tree4663d48aa334558ce2598e2e2541a9e06840906a
parentda67712173474c31695a56a269a8b069f7eb36a6
tools/xenstore: fix node accounting after failed node creation

When a node creation fails the number of nodes of the domain should be
the same as before the failed node creation. In case of failure when
trying to create a node requiring to create one or more intermediate
nodes as well (e.g. when /a/b/c/d is to be created, but /a/b isn't
existing yet) it might happen that the number of nodes of the creating
domain is not reset to the value it had before.

So move the quota accounting out of construct_node() and into the node
write loop in create_node() in order to be able to undo the accounting
in case of an error in the intermediate node destructor.

This is part of XSA-115.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Julien Grall <jgrall@amazon.com>
tools/xenstore/xenstored_core.c